package com.sponsorpay.sdk.android;

import android.content.Context;
import com.sponsorpay.sdk.android.advertiser.SponsorPayAdvertiser;
import com.sponsorpay.sdk.android.credentials.SPCredentials;
import com.sponsorpay.sdk.android.utils.StringUtils;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class SponsorPay
{
  public static final int BUGFIX_RELEASE_NUMBER = 1;
  protected static SponsorPay INSTANCE = new SponsorPay();
  public static final int MAJOR_RELEASE_NUMBER = 4;
  public static final int MINOR_RELEASE_NUMBER;
  public static final String RELEASE_VERSION_STRING;
  private String currentCredentials;
  private HashMap<String, SPCredentials> tokensMap = new HashMap();

  static
  {
    Object[] arrayOfObject = new Object[3];
    arrayOfObject[0] = Integer.valueOf(4);
    arrayOfObject[1] = Integer.valueOf(0);
    arrayOfObject[2] = Integer.valueOf(1);
    RELEASE_VERSION_STRING = String.format("%d.%d.%d", arrayOfObject);
  }

  public static Set<String> getAllCredentials()
  {
    return INSTANCE.tokensMap.keySet();
  }

  public static SPCredentials getCredentials(String paramString)
  {
    return INSTANCE.getCredentialsFromToken(paramString);
  }

  private SPCredentials getCredentialsFromToken(String paramString)
  {
    SPCredentials localSPCredentials = (SPCredentials)this.tokensMap.get(paramString);
    if (localSPCredentials == null)
      throw new RuntimeException("There are no credentials identified by " + paramString + "\nYou have to execute SponsorPay.start method first.");
    return localSPCredentials;
  }

  public static SPCredentials getCurrentCredentials()
  {
    if (StringUtils.nullOrEmpty(INSTANCE.currentCredentials))
      throw new RuntimeException("No credentials object was created yet.\nYou have to execute SponsorPay.start method first.");
    return INSTANCE.getCredentialsFromToken(INSTANCE.currentCredentials);
  }

  public static String start(String paramString1, String paramString2, String paramString3, Context paramContext)
  {
    HashSet localHashSet = new HashSet(getAllCredentials());
    String str = INSTANCE.getCredentialsToken(paramString1, paramString2, paramString3, paramContext);
    if (!localHashSet.contains(str))
      SponsorPayAdvertiser.register(paramContext);
    return str;
  }

  protected String getCredentialsToken(String paramString1, String paramString2, String paramString3, Context paramContext)
  {
    SPCredentials localSPCredentials = (SPCredentials)this.tokensMap.get(SPCredentials.getCredentialsToken(paramString1, paramString2));
    if (localSPCredentials == null)
    {
      localSPCredentials = new SPCredentials(paramString1, paramString2, paramString3, paramContext);
      this.tokensMap.put(localSPCredentials.getCredentialsToken(), localSPCredentials);
    }
    while (true)
    {
      this.currentCredentials = localSPCredentials.getCredentialsToken();
      return this.currentCredentials;
      if (StringUtils.notNullNorEmpty(paramString3))
        localSPCredentials.setSecurityToken(paramString3);
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.SponsorPay
 * JD-Core Version:    0.6.2
 */